package cn.wit.summit.chwan.adapters;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.wit.summit.chwan.R;
import cn.wit.summit.chwan.Stat.AdPosition;
import cn.wit.summit.chwan.Stat.StatFactory;
import cn.wit.summit.chwan.models.dto.GameListBaseBean;
import cn.wit.summit.chwan.models.dto.GameTagInfoBean;
import cn.wit.summit.chwan.models.dto.IntentDataBean;
import cn.wit.summit.chwan.models.dto.JumpBaseBean;
import cn.wit.summit.chwan.ui.base.MyActivity;
import cn.wit.summit.chwan.utils.IntentUtil;
import cn.wit.summit.chwan.utils.StringUtils;
import cn.wit.summit.chwan.widgets.CountdownView;
import cn.wit.summit.chwan.widgets.ItemGridDownloadBestView;
import cn.wit.summit.chwan.widgets.ItemGridDownloadView;
import cn.wit.summit.chwan.widgets.ItemListPartView;
import cn.wit.summit.chwan.widgets.ItemListView;

/**
 * Created by Alan on 2018/4/4.
 */

public class RecommendAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private List<ViewBean> mDatas;
    private Activity mContext;
    private LayoutInflater inflater;
    private CountdownView.OnCountdownListener mOnCountdownListener;

    private LinearLayout.LayoutParams paramsNew;
    private ViewGroup.LayoutParams paramsRl;

    private Map<String, String> downTemp = new HashMap<>();
    private boolean isTitle = false;

    private Drawable drawable;

    public RecommendAdapter(Activity context, List<ViewBean> datas, CountdownView.OnCountdownListener mOnCountdownListener) {
        this.mContext = context;
        this.mDatas = datas;
        this.mOnCountdownListener = mOnCountdownListener;
        inflater = LayoutInflater.from(mContext);

        drawable = mContext.getResources().getDrawable(R.mipmap.conner_tip);

        Display display = ((MyActivity)context).getWindowManager().getDefaultDisplay();
        int w = display.getWidth();
        int h = w * 302 /720;
        paramsNew = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, h);
        h = w * 192 /720;
        paramsRl = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, h);
    }

    public String getPoByGameId(String gameId) {
        String result = "";
        if (downTemp.size()>0 && downTemp.containsKey(gameId)){
            result = downTemp.get(gameId);
        }
        return result;
    }
    public void clearTempData () {
        downTemp.clear();
    }

    public GameListBaseBean getBeanData(int itemPo, int po) {
        if (mDatas.get(itemPo).getViewType() == ViewType.TYPE_GRID) {
            List<GameListBaseBean> list = (List<GameListBaseBean>) mDatas.get(itemPo).getObj();
            return list.get(po);
        } else if (mDatas.get(itemPo).getViewType() == ViewType.TYPE_BEST_MONTH) {
            JumpBaseBean tempJump = (JumpBaseBean) mDatas.get(itemPo).getObj();
            List<GameListBaseBean> list = tempJump.getGame_list();
            return list.get(po);
        } else if (mDatas.get(itemPo).getViewType() == ViewType.TYPE_LIST) {
            GameListBaseBean list = (GameListBaseBean) mDatas.get(itemPo).getObj();
            return list;
        } else if (mDatas.get(itemPo).getViewType() == ViewType.TYPE_PAST_LIST) {
            JumpBaseBean tempJump = (JumpBaseBean) mDatas.get(itemPo).getObj();
            List<GameListBaseBean> list = tempJump.getGame_list();
            return list.get(0);
        }
        return null;
    }

    public enum ViewType {
        TYPE_IMAGE,//banner图片
        TYPE_NEW_GAME,//每日上新和每日首发
        TYPE_BEST_MONTH,//月最佳
        TYPE_SP_COLLECTION,//合并专题列表
        TYPE_LINE_1PX,//合并专题列表分割线
        TYPE_PAST_COLLECTION,//往期专题
        TYPE_PAST_TITLE,//往期经典标题
        TYPE_PAST_IMAGE,//往期图片
        TYPE_PAST_LIST,//往期游戏
        TYPE_PAST_LIST_LINE,//往期游戏line
        TYPE_TITLE,
        TYPE_GRID,
        TYPE_LIST
    }

    public static class ViewBean {
        ViewType viewType;
        Object obj;

        public ViewBean() {
        }

        public ViewBean(ViewType viewType, Object obj) {
            this.viewType = viewType;
            this.obj = obj;
        }

        public ViewType getViewType() {
            return viewType;
        }

        public void setViewType(ViewType viewType) {
            this.viewType = viewType;
        }

        public Object getObj() {
            return obj;
        }

        public void setObj(Object obj) {
            this.obj = obj;
        }
    }

    @Override
    public int getItemCount() {
        return mDatas.size();
    }

    //设置ITEM类型，可以自由发挥，这里设置item position单数显示item1 偶数显示item2
    @Override
    public int getItemViewType(int position) {
        if (mDatas != null) {
            return mDatas.get(position).getViewType().ordinal();
        }
        return -1;
    }

    //重写onCreateViewHolder方法，返回一个自定义的ViewHolder
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        RecyclerView.ViewHolder holder = null;

        //加载Item View的时候根据不同TYPE加载不同的布局
        if (viewType == ViewType.TYPE_IMAGE.ordinal()) {
            holder = new ImageHolder(inflater.inflate(R.layout.item_recommend_image_view, parent, false));
        } else if (viewType == ViewType.TYPE_NEW_GAME.ordinal()) {
            holder = new NewGameHolder(inflater.inflate(R.layout.item_recommend_new_game_view, parent, false));
        } else if (viewType == ViewType.TYPE_BEST_MONTH.ordinal()) {
            holder = new BestMonthHolder(inflater.inflate(R.layout.item_recommend_best_month_view, parent, false));
        } else if (viewType == ViewType.TYPE_SP_COLLECTION.ordinal()) {
            holder = new SpCollectionHolder(inflater.inflate(R.layout.item_recommend_sp_collection_view, parent, false));
        } else if (viewType == ViewType.TYPE_LINE_1PX.ordinal()) {
            holder = new SpCollectionLineHolder(inflater.inflate(R.layout.item_recommend_sp_collection_line_view, parent, false));
        } else if (viewType == ViewType.TYPE_PAST_COLLECTION.ordinal()) {
            holder = new PastCollectionLineHolder(inflater.inflate(R.layout.item_recommend_past_collection_view, parent, false));
        } else if (viewType == ViewType.TYPE_PAST_TITLE.ordinal()) {
            holder = new PastTitleHolder(inflater.inflate(R.layout.item_recommend_past_title_view, parent, false));
        } else if (viewType == ViewType.TYPE_PAST_IMAGE.ordinal()) {
            holder = new PastImageHolder(inflater.inflate(R.layout.item_recommend_past_image_view, parent, false));
        } else if (viewType == ViewType.TYPE_PAST_LIST.ordinal()) {
            holder = new PastListHolder(inflater.inflate(R.layout.item_recommend_past_list_view, parent, false));
        } else if (viewType == ViewType.TYPE_PAST_LIST_LINE.ordinal()) {
            holder = new PastLineHolder(inflater.inflate(R.layout.item_recommend_past_line_view, parent, false));
        } else if (viewType == ViewType.TYPE_TITLE.ordinal()) {
            holder = new TitleHolder(inflater.inflate(R.layout.item_recommend_title_view, parent, false));
        } else if (viewType == ViewType.TYPE_GRID.ordinal()) {
            holder = new GridHolder(inflater.inflate(R.layout.item_recommend_grid_view, parent, false));
        } else if (viewType == ViewType.TYPE_LIST.ordinal()) {
            holder = new ListHolder(inflater.inflate(R.layout.item_recommend_list_view, parent, false));
        }

        return holder;
    }

    //填充onCreateViewHolder方法返回的holder中的控件
    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int position) {

        ViewBean viewBean = mDatas.get(position);
        if (holder instanceof ImageHolder) {//图片item
            final JumpBaseBean temp = (JumpBaseBean) viewBean.getObj();
            ImageHolder imageHolder = (ImageHolder) holder;
            imageHolder.itemRecommendIv.setImageURI(temp.getJump_cover_big_pic());
            imageHolder.itemRecommendIv.setOnClickListener(new MyListener(mContext, temp));
        } else if (holder instanceof TitleHolder) {
            isTitle = true;
            final JumpBaseBean temp = (JumpBaseBean) viewBean.getObj();
            TitleHolder titleHolder = (TitleHolder) holder;
            titleHolder.titleTv.setText(temp.getJump_title());
            titleHolder.titleLableTv.setText(temp.getJump_sub_title());
            titleHolder.titleRightTv.setText(temp.getJump_label());
            titleHolder.rootRl.setOnClickListener(new MyListener(mContext, temp));
        } else if (holder instanceof PastTitleHolder) {
            isTitle = true;
//            final JumpBaseBean temp = (JumpBaseBean) viewBean.getObj();
//            PastTitleHolder pastTitleHolder = (PastTitleHolder) holder;
//            pastTitleHolder.itemPastTitleTx.setText(temp.getJump_title());
        } else if (holder instanceof ListHolder) {
            GameListBaseBean listTemp = (GameListBaseBean) viewBean.getObj();
            ListHolder listHolder = (ListHolder) holder;

            downTemp.put(listTemp.getGame_id(), position+"");
            listHolder.listItem.setDataNotagInfo(mContext,listTemp);
            if (isTitle) {
                listHolder.listItem.hitLine();
                isTitle = false;
            } else {
                listHolder.listItem.showLine();
            }
        } else if (holder instanceof PastImageHolder) {
            final JumpBaseBean jumpBaseBean = (JumpBaseBean) viewBean.getObj();
            PastImageHolder pastImageHolder = (PastImageHolder) holder;

            if (jumpBaseBean!=null && !StringUtils.isEmpty(jumpBaseBean.getJump_cover_big_pic()))
                pastImageHolder.itemGameStarterIv.setImageURI(jumpBaseBean.getJump_cover_big_pic());
            else {
                Uri uri = Uri.parse("res:///" + R.drawable.main_normal_horizontal_short_icon);
                pastImageHolder.itemGameStarterIv.setImageURI(uri);
            }
            pastImageHolder.itemGameStarterIv.setOnClickListener(new MyListener(mContext, jumpBaseBean));
            pastImageHolder.itemImageTimeTx.setText(jumpBaseBean.getJump_time());
        } else if (holder instanceof PastListHolder) {
            JumpBaseBean tempJump = (JumpBaseBean) viewBean.getObj();
            List<GameListBaseBean> list = tempJump.getGame_list();
            PastListHolder pastListHolder = (PastListHolder) holder;
            if (tempJump!=null && list!=null && list.size()>0) {
                downTemp.put(list.get(0).getGame_id(), position+"");
                pastListHolder.itemListPartView.setData(mContext, list.get(0), false, 1, tempJump.getPosition());
            }
        } else if (holder instanceof BestMonthHolder) {
            final JumpBaseBean tempJump = (JumpBaseBean) viewBean.getObj();
            BestMonthHolder bestMonthHolder = (BestMonthHolder) holder;

            bestMonthHolder.recommendBestMonthMoreTx.setOnClickListener(new MyListener(mContext, tempJump));
            bestMonthHolder.recommendBestMonthTitleTx.setText(tempJump.getJump_title());

            bestMonthHolder.itemGridDownloadViewOne.setVisibility(View.INVISIBLE);
            bestMonthHolder.itemGridDownloadViewTwo.setVisibility(View.INVISIBLE);
            bestMonthHolder.itemGridDownloadViewThree.setVisibility(View.INVISIBLE);
            bestMonthHolder.itemGridDownloadViewFour.setVisibility(View.INVISIBLE);
            bestMonthHolder.itemGridDownloadViewFive.setVisibility(View.INVISIBLE);
            List<GameListBaseBean> list = tempJump.getGame_list();

            if (list!=null && list.size()>0) {
                for (int i=0;i<list.size();i++) {
                    GameListBaseBean temp = list.get(i);
                    downTemp.put(temp.getGame_id(), position+"|"+i+"|"+1);
                    switch (i) {
                        case 0:
                            bestMonthHolder.itemGridDownloadViewOne.setVisibility(View.VISIBLE);
                            bestMonthHolder.itemGridDownloadViewOne.setData(mContext, temp, drawable, 1);
                            break;
                        case 1:
                            bestMonthHolder.itemGridDownloadViewTwo.setVisibility(View.VISIBLE);
                            bestMonthHolder.itemGridDownloadViewTwo.setData(mContext, temp, drawable, 2);
                            break;
                        case 2:
                            bestMonthHolder.itemGridDownloadViewThree.setVisibility(View.VISIBLE);
                            bestMonthHolder.itemGridDownloadViewThree.setData(mContext, temp, drawable, 3);
                            break;
                        case 3:
                            bestMonthHolder.itemGridDownloadViewFour.setVisibility(View.VISIBLE);
                            bestMonthHolder.itemGridDownloadViewFour.setData(mContext, temp, drawable, 4);
                            break;
                        case 4:
                            bestMonthHolder.itemGridDownloadViewFive.setVisibility(View.VISIBLE);
                            bestMonthHolder.itemGridDownloadViewFive.setData(mContext, temp, drawable, 5);
                            break;
                    }
                }
            }
        } else if (holder instanceof GridHolder) {
            List<GameListBaseBean> list = (List<GameListBaseBean>) viewBean.getObj();
            GridHolder gridHolder = (GridHolder) holder;

            gridHolder.itemGridDownloadViewOne.setVisibility(View.INVISIBLE);
            gridHolder.itemGridDownloadViewTwo.setVisibility(View.INVISIBLE);
            gridHolder.itemGridDownloadViewThree.setVisibility(View.INVISIBLE);

            for (int i=0;i<list.size();i++) {
                GameListBaseBean temp = list.get(i);
                downTemp.put(temp.getGame_id(), position+"|"+i+"|"+0);
                switch (i) {
                    case 0:
                        gridHolder.itemGridDownloadViewOne.setVisibility(View.VISIBLE);
                        gridHolder.itemGridDownloadViewOne.setData(mContext,temp);
                        break;
                    case 1:
                        gridHolder.itemGridDownloadViewTwo.setVisibility(View.VISIBLE);
                        gridHolder.itemGridDownloadViewTwo.setData(mContext,temp);
                        break;
                    case 2:
                        gridHolder.itemGridDownloadViewThree.setVisibility(View.VISIBLE);
                        gridHolder.itemGridDownloadViewThree.setData(mContext,temp);
                        break;
                }
            }
        } else if (holder instanceof PastCollectionLineHolder) {
            final JumpBaseBean tempJump = (JumpBaseBean) viewBean.getObj();
            PastCollectionLineHolder pastCollectionLineHolder = (PastCollectionLineHolder) holder;
            pastCollectionLineHolder.itemPastCollectionRootLl.setLayoutParams(paramsRl);
            pastCollectionLineHolder.itemPastCollectionRootLl.setOnClickListener(new MyListener(mContext, tempJump));
            pastCollectionLineHolder.itemPastCollectionTitleTx.setText(tempJump.getJump_title());
            pastCollectionLineHolder.itemPastCollectionSubTx.setText(tempJump.getJump_sub_title());
            pastCollectionLineHolder.itemPastCollectionIv.setImageURI(tempJump.getJump_cover_big_pic());
            pastCollectionLineHolder.itemPastCollectionRl.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    IntentDataBean bean = new IntentDataBean();
                    bean.setJump_type(9);
                    bean.setJump_link_type(3);
                    IntentUtil.getInstance().intentTo(mContext, bean);
                    StatFactory.getInstance().sendClickAdvertSpacePage(mContext, AdPosition.getModeByEnum(4)
                            , AdPosition.getNameByEnum(4),"","", 6);
                }
            });
        } else if (holder instanceof NewGameHolder) {
            List<JumpBaseBean> list = (List<JumpBaseBean>) viewBean.getObj();
            NewGameHolder newGameHolder = (NewGameHolder) holder;
            newGameHolder.itemRecommendNewRootLl.setLayoutParams(paramsNew);
            for (int i=0;i<list.size();i++) {
                final JumpBaseBean temp = (JumpBaseBean) list.get(i);
                if (temp!=null) {
                    switch (i) {
                        case 0:
                            newGameHolder.itemRecommendNewLeftRl.setOnClickListener(new MyListener(mContext, temp));
                            newGameHolder.countdownView.setNowTime(temp.getSurplus_times(), new CountdownView.OnCountdownListener() {
                                @Override
                                public void onResult(long time) {
                                    temp.setSurplus_times(time);
                                    mOnCountdownListener.onResult(time);
                                }
                            });
                            String imgUrl = temp.getJump_cover_big_pic();
                            String labUrl = temp.getJump_title();
                            String tag = temp.getJump_is_crack();
                            if (!StringUtils.isEmpty(imgUrl)) {
                                String[] img = imgUrl.split("\\|");
                                if (img.length>=2) {
                                    newGameHolder.itemRecommendNewOneIv.setImageURI(img[0]);
                                    newGameHolder.itemRecommendNewTwoIv.setImageURI(img[1]);
                                } else {
                                    newGameHolder.itemRecommendNewOneIv.setImageURI(img[0]);
                                }
                            }
                            if (!StringUtils.isEmpty(labUrl)) {
                                String[] title = labUrl.split("\\|");
                                if (title.length>=2) {
                                    newGameHolder.itemRecommendNewOneTv.setText(title[0]);
                                    newGameHolder.itemRecommendNewTwoTv.setText(title[1]);
                                } else {
                                    newGameHolder.itemRecommendNewOneTv.setText(title[0]);
                                }
                            }
                            if (!StringUtils.isEmpty(tag)) {
                                String[] gameTag = tag.split("\\|");
                                for (int s=0;s<gameTag.length;s++) {
                                    if (s==0 && gameTag[s].equals("1")) {
                                        newGameHolder.itemRecommendNewOneIv.getHierarchy().setOverlayImage(drawable);
                                    } else if (s==1 && gameTag[s].equals("1")) {
                                        newGameHolder.itemRecommendNewTwoIv.getHierarchy().setOverlayImage(drawable);
                                    }
                                }
                            }
                            if (temp.getGame_list()!=null) {
                                for (int m=0;i<temp.getGame_list().size();i++) {
                                    GameListBaseBean da = temp.getGame_list().get(m);
                                    List<GameTagInfoBean> gameTagInfoBeans=temp.getGame_list().get(m).getGame_tag_info();
                                    switch (m) {
                                        case 0:
                                            newGameHolder.itemRecommendNewOneIv.setImageURI(da.getGame_ico());
                                            newGameHolder.itemRecommendNewOneTv.setText(da.getGame_name());
                                            if (gameTagInfoBeans!=null){
                                                for (GameTagInfoBean bean:gameTagInfoBeans){
                                                    if (bean.getId().equals("25")){
                                                        newGameHolder.itemRecommendNewOneIv.getHierarchy().setOverlayImage(drawable);
                                                        break;
                                                    } else {
                                                        newGameHolder.itemRecommendNewOneIv.getHierarchy().setOverlayImage(null);
                                                    }
                                                }
                                            }
                                            break;
                                        case 1:
                                            newGameHolder.itemRecommendNewTwoIv.setImageURI(da.getGame_ico());
                                            newGameHolder.itemRecommendNewTwoTv.setText(da.getGame_name());
                                            if (gameTagInfoBeans!=null){
                                                for (GameTagInfoBean bean:gameTagInfoBeans){
                                                    if (bean.getId().equals("25")){
                                                        newGameHolder.itemRecommendNewTwoIv.getHierarchy().setOverlayImage(drawable);
                                                        break;
                                                    } else {
                                                        newGameHolder.itemRecommendNewOneIv.getHierarchy().setOverlayImage(null);
                                                    }
                                                }
                                            }
                                            break;
                                    }
                                }
                            }
                            break;
                        case 1:
                            newGameHolder.itemRecommendNewRightRl.setOnClickListener(new MyListener(mContext, temp));
                            newGameHolder.itemRecommendNewThreeIv.setImageURI(temp.getJump_cover_big_pic());
                            newGameHolder.itemRecommendNewThreeTv.setText(temp.getJump_label());
                            newGameHolder.itemRecommendNewTitleThreeTv.setText(temp.getJump_title());
                            newGameHolder.itemRecommendDayTv.setText(temp.getJump_sub_title());
                            if (temp.getGame_list()!=null && temp.getGame_list().size()>0) {
                                List<GameTagInfoBean> gameTagInfoBeans=temp.getGame_list().get(0).getGame_tag_info();
                                if (gameTagInfoBeans!=null){
                                    for (GameTagInfoBean bean:gameTagInfoBeans){
                                        if (bean.getId().equals("25")){
                                            newGameHolder.itemRecommendNewThreeIv.getHierarchy().setOverlayImage(drawable);
                                            break;
                                        } else {
                                            newGameHolder.itemRecommendNewThreeIv.getHierarchy().setOverlayImage(null);
                                        }
                                    }
                                }
                            }
                            break;
                    }
                }
            }
        } else if (holder instanceof SpCollectionHolder) {
            List<JumpBaseBean> list = (List<JumpBaseBean>) viewBean.getObj();
            SpCollectionHolder spCollectionHolder = (SpCollectionHolder) holder;

            spCollectionHolder.itemSpCollectionLeftRl.setVisibility(View.INVISIBLE);
            spCollectionHolder.itemSpCollectionRightRl.setVisibility(View.INVISIBLE);

            for (int i=0;i<list.size();i++) {
                final JumpBaseBean temp = (JumpBaseBean) list.get(i);
                if (temp!=null) {
                    switch (i) {
                        case 0:
                            spCollectionHolder.itemSpCollectionLeftRl.setVisibility(View.VISIBLE);
                            spCollectionHolder.itemSpCollectionLeftRl.setOnClickListener(new MyListener(mContext, temp));
                            spCollectionHolder.itemSpCollectionLeftTitleTx.setText(temp.getJump_sub_title());
                            spCollectionHolder.itemSpCollectionLeftSubTx.setText(temp.getJump_label());
                            if (!StringUtils.isEmpty(temp.getJump_title())) {
                                String[] gameName = temp.getJump_title().split("\\|");
                                spCollectionHolder.itemSpCollectionLeftOneTv.setText(gameName[0]);
                                if (gameName.length>=2)
                                    spCollectionHolder.itemSpCollectionLeftTwoTv.setText(gameName[1]);
                            }
                            if (!StringUtils.isEmpty(temp.getJump_cover_big_pic())) {
                                String[] gameIco = temp.getJump_cover_big_pic().split("\\|");
                                spCollectionHolder.itemSpCollectionLeftOneIv.setImageURI(gameIco[0]);
                                if (gameIco.length>=2)
                                    spCollectionHolder.itemSpCollectionLeftTwoIv.setImageURI(gameIco[1]);
                            }
                            if (!StringUtils.isEmpty(temp.getJump_is_crack())) {
                                String[] gameTag = temp.getJump_is_crack().split("\\|");
                                for (int s=0;s<gameTag.length;s++) {
                                    if (s==0 && gameTag[s].equals("1")) {
                                        spCollectionHolder.itemSpCollectionLeftOneIv.getHierarchy().setOverlayImage(drawable);
                                    } else if (s==1 && gameTag[s].equals("1")) {
                                        spCollectionHolder.itemSpCollectionLeftTwoIv.getHierarchy().setOverlayImage(drawable);
                                    }
                                }
                            }
                            break;
                        case 1:
                            spCollectionHolder.itemSpCollectionRightRl.setVisibility(View.VISIBLE);
                            spCollectionHolder.itemSpCollectionRightRl.setOnClickListener(new MyListener(mContext, temp));
                            spCollectionHolder.itemSpCollectionRightTitleTx.setText(temp.getJump_sub_title());
                            spCollectionHolder.itemSpCollectionRightSubTx.setText(temp.getJump_label());
                            if (!StringUtils.isEmpty(temp.getJump_title())) {
                                String[] gameName = temp.getJump_title().split("\\|");
                                spCollectionHolder.itemSpCollectionRightOneTv.setText(gameName[0]);
                                if (gameName.length>=2)
                                    spCollectionHolder.itemSpCollectionRightTwoTv.setText(gameName[1]);
                            }
                            if (!StringUtils.isEmpty(temp.getJump_cover_big_pic())) {
                                String[] gameIco = temp.getJump_cover_big_pic().split("\\|");
                                spCollectionHolder.itemSpCollectionRightOneIv.setImageURI(gameIco[0]);
                                if (gameIco.length>=2)
                                    spCollectionHolder.itemSpCollectionRightTwoIv.setImageURI(gameIco[1]);
                            }
                            if (!StringUtils.isEmpty(temp.getJump_is_crack())) {
                                String[] gameTag = temp.getJump_is_crack().split("\\|");
                                for (int s=0;s<gameTag.length;s++) {
                                    if (s==0 && gameTag[s].equals("1")) {
                                        spCollectionHolder.itemSpCollectionRightOneIv.getHierarchy().setOverlayImage(drawable);
                                    } else if (s==1 && gameTag[s].equals("1")) {
                                        spCollectionHolder.itemSpCollectionRightTwoIv.getHierarchy().setOverlayImage(drawable);
                                    }
                                }
                            }
                            break;
                    }
                }
            }
        }
    }

    private class MyListener implements View.OnClickListener {

        private Activity context;
        private JumpBaseBean tempBean;

        public MyListener(Activity context, JumpBaseBean temp) {
            this.context = context;
            this.tempBean = temp;
        }

        @Override
        public void onClick(View v) {
            IntentUtil.getInstance().intentTo(context, tempBean);
            String mode = tempBean.getDotMode();
            String name = tempBean.getDotName();
            if (!StringUtils.isEmpty(mode) && !StringUtils.isEmpty(name)) {
                StatFactory.getInstance().sendClickAdvertSpacePage(mContext
                        , mode, name,"","", tempBean.getPosition());
            }
        }
    }

    public class ImageHolder extends RecyclerView.ViewHolder {
        SimpleDraweeView itemRecommendIv;

        public ImageHolder(View view) {
            super(view);
            itemRecommendIv = view.findViewById(R.id.itemRecommendIv);
        }
    }

    public class BestMonthHolder extends RecyclerView.ViewHolder {
        TextView recommendBestMonthMoreTx;
        TextView recommendBestMonthTitleTx;
        ItemGridDownloadBestView itemGridDownloadViewOne;
        ItemGridDownloadBestView itemGridDownloadViewTwo;
        ItemGridDownloadBestView itemGridDownloadViewThree;
        ItemGridDownloadBestView itemGridDownloadViewFour;
        ItemGridDownloadBestView itemGridDownloadViewFive;

        public BestMonthHolder(View view) {
            super(view);
            recommendBestMonthMoreTx = view.findViewById(R.id.recommendBestMonthMoreTx);
            recommendBestMonthTitleTx = view.findViewById(R.id.recommendBestMonthTitleTx);
            itemGridDownloadViewOne = view.findViewById(R.id.itemGridDownloadViewOne);
            itemGridDownloadViewTwo = view.findViewById(R.id.itemGridDownloadViewTwo);
            itemGridDownloadViewThree = view.findViewById(R.id.itemGridDownloadViewThree);
            itemGridDownloadViewFour = view.findViewById(R.id.itemGridDownloadViewFour);
            itemGridDownloadViewFive = view.findViewById(R.id.itemGridDownloadViewFive);
        }
    }

    public class SpCollectionHolder extends RecyclerView.ViewHolder {

        RelativeLayout itemSpCollectionLeftRl;
        TextView itemSpCollectionLeftTitleTx;
        TextView itemSpCollectionLeftSubTx;
        SimpleDraweeView itemSpCollectionLeftOneIv;
        SimpleDraweeView itemSpCollectionLeftTwoIv;
        TextView itemSpCollectionLeftOneTv;
        TextView itemSpCollectionLeftTwoTv;
        RelativeLayout itemSpCollectionRightRl;
        TextView itemSpCollectionRightTitleTx;
        TextView itemSpCollectionRightSubTx;
        SimpleDraweeView itemSpCollectionRightOneIv;
        SimpleDraweeView itemSpCollectionRightTwoIv;
        TextView itemSpCollectionRightOneTv;
        TextView itemSpCollectionRightTwoTv;

        public SpCollectionHolder(View view) {
            super(view);
            itemSpCollectionLeftRl = view.findViewById(R.id.itemSpCollectionLeftRl);
            itemSpCollectionLeftTitleTx = view.findViewById(R.id.itemSpCollectionLeftTitleTx);
            itemSpCollectionLeftSubTx = view.findViewById(R.id.itemSpCollectionLeftSubTx);
            itemSpCollectionLeftOneIv = view.findViewById(R.id.itemSpCollectionLeftOneIv);
            itemSpCollectionLeftTwoIv = view.findViewById(R.id.itemSpCollectionLeftTwoIv);
            itemSpCollectionLeftOneTv = view.findViewById(R.id.itemSpCollectionLeftOneTv);
            itemSpCollectionLeftTwoTv = view.findViewById(R.id.itemSpCollectionLeftTwoTv);
            itemSpCollectionRightRl = view.findViewById(R.id.itemSpCollectionRightRl);
            itemSpCollectionRightTitleTx = view.findViewById(R.id.itemSpCollectionRightTitleTx);
            itemSpCollectionRightSubTx = view.findViewById(R.id.itemSpCollectionRightSubTx);
            itemSpCollectionRightOneIv = view.findViewById(R.id.itemSpCollectionRightOneIv);
            itemSpCollectionRightTwoIv = view.findViewById(R.id.itemSpCollectionRightTwoIv);
            itemSpCollectionRightOneTv = view.findViewById(R.id.itemSpCollectionRightOneTv);
            itemSpCollectionRightTwoTv = view.findViewById(R.id.itemSpCollectionRightTwoTv);
        }
    }

    public class SpCollectionLineHolder extends RecyclerView.ViewHolder {

        public SpCollectionLineHolder(View view) {
            super(view);
        }
    }

    public class PastTitleHolder extends RecyclerView.ViewHolder {
        TextView itemPastTitleTx;

        public PastTitleHolder(View view) {
            super(view);
            itemPastTitleTx = view.findViewById(R.id.itemPastTitleTx);
        }
    }

    public class PastImageHolder extends RecyclerView.ViewHolder {
        RelativeLayout itemImageRootRl;
        SimpleDraweeView itemGameStarterIv;
        TextView itemImageTimeTx;

        public PastImageHolder(View view) {
            super(view);
            itemImageRootRl = view.findViewById(R.id.itemImageRootRl);
            itemGameStarterIv = view.findViewById(R.id.itemGameStarterIv);
            itemImageTimeTx = view.findViewById(R.id.itemImageTimeTx);
        }
    }

    public class PastListHolder extends RecyclerView.ViewHolder {
        ItemListPartView itemListPartView;

        public PastListHolder(View view) {
            super(view);
            itemListPartView = view.findViewById(R.id.itemListPartView);
        }
    }

    public class PastLineHolder extends RecyclerView.ViewHolder {

        public PastLineHolder(View view) {
            super(view);
        }
    }

    public class PastCollectionLineHolder extends RecyclerView.ViewHolder {
        LinearLayout itemPastCollectionRootLl;
        SimpleDraweeView itemPastCollectionIv;
        TextView itemPastCollectionTitleTx;
        TextView itemPastCollectionSubTx;
        RelativeLayout itemPastCollectionRl;

        public PastCollectionLineHolder(View view) {
            super(view);
            itemPastCollectionRl = view.findViewById(R.id.itemPastCollectionRl);
            itemPastCollectionRootLl = view.findViewById(R.id.itemPastCollectionRootLl);
            itemPastCollectionIv = view.findViewById(R.id.itemPastCollectionIv);
            itemPastCollectionTitleTx = view.findViewById(R.id.itemPastCollectionTitleTx);
            itemPastCollectionSubTx = view.findViewById(R.id.itemPastCollectionSubTx);
        }
    }

    public class TitleHolder extends RecyclerView.ViewHolder {
        RelativeLayout rootRl;
        TextView titleTv;
        TextView titleRightTv;
        TextView titleLableTv;

        public TitleHolder(View view) {
            super(view);
            rootRl = view.findViewById(R.id.rootRl);
            titleTv = view.findViewById(R.id.titleTv);
            titleRightTv = view.findViewById(R.id.titleRightTv);
            titleLableTv = view.findViewById(R.id.titleLableTv);
        }
    }

    public class ListHolder extends RecyclerView.ViewHolder {
        ItemListView listItem;

        public ListHolder(View view) {
            super(view);
            listItem = view.findViewById(R.id.listItem);
        }
    }

    public class GridHolder extends RecyclerView.ViewHolder {

        ItemGridDownloadView itemGridDownloadViewOne;
        ItemGridDownloadView itemGridDownloadViewTwo;
        ItemGridDownloadView itemGridDownloadViewThree;

        public GridHolder(View view) {
            super(view);
            itemGridDownloadViewOne = view.findViewById(R.id.itemGridDownloadViewOne);
            itemGridDownloadViewTwo = view.findViewById(R.id.itemGridDownloadViewTwo);
            itemGridDownloadViewThree = view.findViewById(R.id.itemGridDownloadViewThree);
        }
    }

    public class NewGameHolder extends RecyclerView.ViewHolder {
        LinearLayout itemRecommendNewRootLl;
        CountdownView countdownView;
        SimpleDraweeView itemRecommendNewOneIv;
        SimpleDraweeView itemRecommendNewTwoIv;
        TextView itemRecommendNewOneTv;
        TextView itemRecommendNewTwoTv;
        TextView itemRecommendDayTv;
        SimpleDraweeView itemRecommendNewThreeIv;
        TextView itemRecommendNewThreeTv;
        TextView itemRecommendNewTitleThreeTv;
        RelativeLayout itemRecommendNewRightRl;
        RelativeLayout itemRecommendNewLeftRl;

        public NewGameHolder(View view) {
            super(view);
            itemRecommendNewRootLl = view.findViewById(R.id.itemRecommendNewRootLl);
            countdownView = view.findViewById(R.id.countdownView);
            itemRecommendNewOneIv = view.findViewById(R.id.itemRecommendNewOneIv);
            itemRecommendNewTwoIv = view.findViewById(R.id.itemRecommendNewTwoIv);
            itemRecommendNewOneTv = view.findViewById(R.id.itemRecommendNewOneTv);
            itemRecommendNewTwoTv = view.findViewById(R.id.itemRecommendNewTwoTv);
            itemRecommendDayTv = view.findViewById(R.id.itemRecommendDayTv);
            itemRecommendNewThreeIv = view.findViewById(R.id.itemRecommendNewThreeIv);
            itemRecommendNewThreeTv = view.findViewById(R.id.itemRecommendNewThreeTv);
            itemRecommendNewTitleThreeTv = view.findViewById(R.id.itemRecommendNewTitleThreeTv);
            itemRecommendNewRightRl = view.findViewById(R.id.itemRecommendNewRightRl);
            itemRecommendNewLeftRl = view.findViewById(R.id.itemRecommendNewLeftRl);
        }
    }
}
